<?php
$section = "member";
$titre = _LB_HOME;
$link = $section;
if(!isMemberLoggedIn()){
	redirect(APPLICATION_URL_FO."/");
}
//get object ID
$id = $_SESSION['memberID'];
$act = Request::getIntNumber('act');

//get back link
$backlink = APPLICATION_URL_FO."/member/panel/";

$member = new Member();
if($id)
{
	if(!$member->get($id))
		redirect($backlink);
}

//if action = UPDATE or CREATE
if ($act == ACT_VALID_EDIT)
{  
	if ($member->validateChangePassInput())
	{
		echo $member->PASS = sha1(Request::get("PASS"));
		$member->update();
		redirect(APPLICATION_URL_FO."/member/panel/");
	}

}

//create cfer
$cfer = new Cfer(array(
	_LB_ACCUEIL => APPLICATION_URL_FO,
	_LB_REGISTER => $backlink));

//if validate is false, display form again
$smarty->assign('cfer', $cfer);
$smarty->assign('member', $member);
$smarty->assign('backlink', $backlink);
$smarty->display('member_changepass.html');

